﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace UTDemo
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ClassA a = new ClassA()
            {
                A = "aaa",
                B = "bbb",
                C = "ccc",
                D = string.Empty,
                E = "e",
                F = new Guid(),
                S1 = "",
                S2 = new Guid(),
                S3 = DateTime.Now
            };

            using (SqlConnection conn = new SqlConnection(@"server=192.168.4.253\kxtx;uid=sa;pwd=kxtx816816;database=xtransdb"))
            {
                Guid retId;
                CLFramework.Data.SqlHelper.ExecuteNonQuery<Guid>(conn, "testCreateB"
                    , out retId
                    , a.A
                    , a.B
                    , a.C
                    , a.D
                    , a.E
                    , a.F
                    , a.S1
                    , a.S2
                    , a.S3
                );
                a.ID = retId;
            }

            MessageBox.Show(a.ID.ToString());
        }


    }

    public class ClassA
    {

        /// <summary>
        /// A 构造函数
        /// </summary>
        public ClassA()
        { }


        /// <summary>
        /// A OR映射构造函数
        /// </summary>
        public ClassA(System.Data.IDataReader dr)
        {
            this.ID = (Guid)(dr["ID"]);
            this.A = Convert.ToString(dr["A"]);
            this.B = Convert.ToString(dr["B"]);
            this.C = Convert.ToString(dr["C"]);
            this.D = Convert.ToString(dr["D"]);
            this.E = Convert.ToString(dr["E"]);
            this.F = (Guid)dr["F"];
            this.S1 = Convert.ToString(dr["S1"]);
            this.S2 = (Guid)dr["S2"];
            this.S3 = Convert.ToDateTime(dr["S3"]);
        }

        /// <summary>
        /// 
        /// </summary>
        public Guid ID { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string A { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string B { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string C { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string D { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string E { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid F { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string S1 { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid S2 { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public DateTime S3 { get; set; }


    }

}
